package com.jl.jlapp.mvp.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import com.jl.jlapp.R;
import com.jl.jlapp.mvp.fragment.UserCouponFragment;
import com.jl.jlapp.mvp.fragment.UserCouponFragment.OnGetCouponMsg;
import com.jl.jlapp.mvp.fragment.UserCouponFragment.setOnClickCouponItem;

public class UserCouponActivity
  extends AppCompatActivity
  implements UserCouponFragment.setOnClickCouponItem, UserCouponFragment.OnGetCouponMsg
{
  @BindView(R.id.cupon_use_message)
  TextView cuponUseMessage;
  @BindView(R.id.lay_frame)
  FrameLayout layFrame;
  @BindView(R.id.tv_unUsable)
  TextView tvUnUsable;
  @BindView(R.id.tv_usable)
  TextView tvUsable;
  private UserCouponFragment unUseAble;
  private UserCouponFragment useAble;
  int userId = 0;
  
  private void initView()
  {
    this.useAble = UserCouponFragment.newInstance(1, this.userId);
    this.unUseAble = UserCouponFragment.newInstance(2, this.userId);
    this.useAble.setSetOnClickCouponItem(this);
    this.useAble.setOnGetCouponMsg(this);
    getSupportFragmentManager().beginTransaction().add(R.id.lay_frame, this.useAble).add(R.id.lay_frame, this.unUseAble).show(this.useAble).hide(this.unUseAble).commitAllowingStateLoss();
    final Drawable localDrawable = getResources().getDrawable(R.drawable.splite_green);
    this.tvUsable.setCompoundDrawablesWithIntrinsicBounds(null, null, null, localDrawable);
    this.tvUnUsable.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    this.tvUsable.setOnClickListener(new OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        UserCouponActivity.this.getSupportFragmentManager().beginTransaction().show(UserCouponActivity.this.useAble).hide(UserCouponActivity.this.unUseAble).commitAllowingStateLoss();
        UserCouponActivity.this.tvUsable.setCompoundDrawablesWithIntrinsicBounds(null, null, null, localDrawable);
        UserCouponActivity.this.tvUnUsable.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
      }
    });
    this.tvUnUsable.setOnClickListener(new OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        UserCouponActivity.this.getSupportFragmentManager().beginTransaction().show(UserCouponActivity.this.unUseAble).hide(UserCouponActivity.this.useAble).commitAllowingStateLoss();
        UserCouponActivity.this.tvUsable.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        UserCouponActivity.this.tvUnUsable.setCompoundDrawablesWithIntrinsicBounds(null, null, null, localDrawable);
      }
    });
  }
  
  @OnClick({R.id.return_btn})
  public void onClick(View paramView)
  {
    finish();
  }
  
  public void onClickCouponItem(int paramInt, double paramDouble, String paramString)
  {
    Log.d("aaaaaonClickCouponItem", "couponId:" + paramInt + " price:" + paramDouble + " countMsg:" + paramString);
  }
  
  protected void onCreate(@Nullable Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(R.layout.activity_discount);
    ButterKnife.bind(this);
    this.cuponUseMessage.setVisibility(View.GONE);
    this.userId = getSharedPreferences("JLAppData", 0).getInt("userId", 0);
    if (this.userId > 0)
    {
      initView();
      return;
    }
    Toast.makeText(this, "您还未登录，请先登录。", Toast.LENGTH_SHORT).show();
    startActivity(new Intent(this, LoginActivity.class));
  }
  
  public void onGetCouponMsg(int paramInt1, int paramInt2)
  {
    this.tvUsable.setText("可用优惠券(" + paramInt1 + ")");
    this.tvUnUsable.setText("不可用优惠券(" + paramInt2 + ")");
  }
  
  protected void onResume()
  {
    super.onResume();
  }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/activity/UserCouponActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */